package com.oocl.controller;

import java.util.List;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.oocl.pojo.Customer;
import com.oocl.service.CustomerService;
import com.oocl.service.impl.CustomerServiceFactory;

@Controller
public class CustomerController {
	private CustomerService manager;
	
	public CustomerController() {
		
		manager =CustomerServiceFactory.getInstance();
	}
	@RequestMapping(value="/addCustomer",method=RequestMethod.POST)
	public String addCustomer(Customer c){
		System.out.println(c);
		
		manager.addCustomer(c);
		
		return "redirect:/list";
	}
	
	@RequestMapping(value="/list")
	public String findAllCustomers(Model model){
		List<Customer> customers=manager.findAllCustomers();
		model.addAttribute("customers", customers);
		return "list";
	}
	
	
	
	
	
}














